package com.zxn.japp.interceptor;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.annotation.Interceptor;
import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
import com.alibaba.android.arouter.facade.template.IInterceptor;
import com.zxn.japp.IARouterConfig;

/**
 * Created by zxn on 2020/9/26.
 */
@Interceptor(priority = 1)
public class LoginInterceptor implements IInterceptor {
    private final static String TAG = "LoginInterceptor";

    @Override
    public void process(Postcard postcard, InterceptorCallback callback) {
        Log.i(TAG, "LoginInterceptor called process");
        Log.i(TAG, "group: " + postcard.getGroup() + ", path: " + postcard.getPath());

        if(postcard.getPath().equals(IARouterConfig.HOME_RESULT_ACTIVITY_URL)){
            Log.i(TAG, "路由跳转被登录拦截器拦截了");
            callback.onContinue(postcard);
            //callback.onInterrupt(new Exception("未登录!"));
        }
    }

    @Override
    public void init(Context context) {
        Log.i(TAG, "LoginInterceptor is init");
    }
}
